using CRL.Class2Proto;
using Furion.DatabaseAccessor;
using Furion.JsonSerialization;
using XinGuanERP.Db;

var builder = WebApplication.CreateBuilder(args).Inject();

// Add services to the container.
// Json序列化时忽略属性为null的值
builder.Services.AddControllers().AddJsonOptions(options =>
{
    options.JsonSerializerOptions.DefaultIgnoreCondition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingNull;
    options.JsonSerializerOptions.Converters.Add(new SystemTextJsonDateTimeJsonConverter("yyyy-MM-dd HH:mm:ss"));
});
builder.Services.AddControllers().AddInject();
// 注册数据库上下文
builder.Services.AddDatabaseAccessor(options =>
{
    options.AddDbPool<DefaultDbContext>();
});
builder.Services.AddJwt();
builder.Services.AddGrpc();
var app = builder.Build();
// var convertInfo = ClassConvert.Convert(System.Reflection.Assembly.GetAssembly(typeof(ProductGrpcIService)));
// convertInfo.ForEach(b => b.CreateCode());
// Configure the HTTP request pipeline.

app.UseHttpsRedirection();
app.UseAuthentication();
app.UseAuthorization();

app.UseInject();

app.MapControllers();

app.Run();

